var
    gsAgent = navigator.userAgent.toLowerCase(),
    gsAppVer = navigator.appVersion.toLowerCase(),
    gsAppName = navigator.appName.toLowerCase(),
    gbIsOpera = gsAgent.indexOf("opera") > -1,
    gbIsWebKit = gsAgent.indexOf("applewebkit") > -1,
    gbIsKHTML = gsAgent.indexOf("khtml") > -1 || gsAgent.indexOf("konqueror") > -1 || gbIsWebKit,
    gbIsIE = (gsAgent.indexOf("compatible") > -1 && !gbIsOpera) || gsAgent.indexOf("msie") > -1,
    gbIsTT = gbIsIE ? (gsAppVer.indexOf("tencenttraveler") != -1 ? 1 : 0) : 0,
    gbIsQBWebKit = gbIsWebKit ? (gsAppVer.indexOf("qqbrowser") != -1 ? 1 : 0) : 0,
    gbIsChrome = gbIsWebKit && !gbIsQBWebKit && gsAgent.indexOf("chrome") > -1 && gsAgent.indexOf("se 2.x metasr 1.0") < 0,
    gbIsSafari = gbIsWebKit && !gbIsChrome && !gbIsQBWebKit,
    gbIsQBIE = gbIsIE && gsAppVer.indexOf("qqbrowser") != -1,
    gbIsFF = gsAgent.indexOf("gecko") > -1 && !gbIsKHTML,
    gbIsNS = !gbIsIE && !gbIsOpera && !gbIsKHTML && (gsAgent.indexOf("mozilla") == 0) && (gsAppName == "netscape"),
    gbIsAgentErr = !(gbIsOpera || gbIsKHTML || gbIsSafari || gbIsIE || gbIsTT || gbIsFF || gbIsNS),
    gbIsWin = gsAgent.indexOf("windows") > -1 || gsAgent.indexOf("win32") > -1,
    gbIsVista = gbIsWin && (gsAgent.indexOf("nt 6.0") > -1 || gsAgent.indexOf("windows vista") > -1),
    gbIsWin7 = gbIsWin && gsAgent.indexOf("nt 6.1") > -1,
    gbIsMac = gsAgent.indexOf("macintosh") > -1 || gsAgent.indexOf("mac os x") > -1,
    gsMacVer = /mac os x (\d+)(\.|_)(\d+)/.test(gsAgent) && parseFloat(RegExp.$1 + "." + RegExp.$3),
    gbIsLinux = gsAgent.indexOf("linux") > -1,
    gbIsAir = gsAgent.indexOf("adobeair") > -1,
    gnIEVer = /MSIE (\d+.\d+);/i.test(gsAgent) && parseFloat(RegExp["$1"]),
    gsFFVer = /firefox\/((\d|\.)+)/i.test(gsAgent) && RegExp["$1"],
    gsSafariVer = "" + (/version\/((\d|\.)+)/i.test(gsAgent) && RegExp["$1"]),
    gsChromeVer = "" + (/chrome\/((\d|\.)+)/i.test(gsAgent) && RegExp["$1"]),
    gsQBVer = "" + (/qqbrowser\/((\d|\.)+)/i.test(gsAgent) && RegExp["$1"]),
    bpO = "_For_E_Built";
if (!window.getTop) {
    window.getTop = function () {
        var Qr = arguments.callee;

        if (!Qr.amH) {
            try {
                if (window != parent) {
                    Qr.amH = parent.getTop ? parent.getTop() : parent.parent.getTop();
                } else {
                    Qr.amH = window;
                }
            } catch (aE) {
                Qr.amH = window;
            }
        }

        return Qr.amH;
    };
    try {

    } catch (aE) {
        eval("var top = getTop();");
    }
}
function now() {
    return +new Date;
}
function trim(cw) {
    return (cw && cw.replace ? cw : "").replace(/(^\s*)|(\s*$)/g, "");
}
function trim2(cw) {

    if (cw && cw.substring) {
        var rH = /\s/,
            JF = -1,
            JI = cw.length;
        while (rH.test(cw.charAt(--JI)));
        while (rH.test(cw.charAt(++JF)));
        return cw.substring(JF, JI + 1);
    }
}

function regFilter(akp) {
    return akp.replace(/([\^\.\[\$\(\)\|\*\+\?\{\\])/ig, "\\$1");
}

function E(WS, atl, aOR, akT) {
    if (!WS) {
        return;
    }

    if (WS.length != null) {
        var be = WS.length,
            lB;

        if (akT < 0) {
            lB = be + akT;
        } else {
            lB = akT < be ? akT : be;
        }

        for (var i = (aOR || 0); i < lB; i++) {
            try {
                if (atl(WS[i], i, be) === false) {
                    break;
                }
            } catch (aE) {

            }
        }
    } else {
        for (var i in WS) {
            try {
                if (atl(WS[i], i) === false) {
                    break;
                }
            } catch (aE) {

            }
        }
    }
}
function S(bp, hB) {
    try {
        return (hB && (hB.document || hB) || document).getElementById(bp);
    } catch (aE) {
        return null;
    }
}
function SN(ba, hB) {
    try {
        var apn = (hB && (hB.document || hB) || document).getElementsByName(ba);
        if (apn) {
            apn[bpO] = true;
        }
        return apn;
    } catch (aE) {
        return null;
    }
}
function attr(ar, fE, aK) {

    if (!ar || !ar.nodeType || ar.nodeType === 3 || ar.nodeType === 8) {
        return undefined;
    }
    if (aK === undefined) {
        return ar.getAttribute(fE);
    } else {
        ar.setAttribute(fE, aK);
        return ar;
    }
}
//function GelTags(fL, dp) {
//    var apn = (dp || document).getElementsByTagName(fL);
//    if (apn) {
//        apn[bpO] = true;
//    }
//    return apn;
//
//}
function F(bp, aB) {
    var Sr = S(bp, aB);
    return Sr && (Sr.contentWindow || (aB || window).frames[bp]);
}
//function appendToUrl(aD, deh) {
//    var cq = aD.split("#");
//    return [cq[0], deh, (cq.length > 1 ? "#" + cq[1] : "")].join("");
//}
function insertHTML(dp, gu, dJ) {
    if (!dp) {
        return false;
    }
    try {

        if (dp.insertAdjacentHTML) {
            dp.insertAdjacentHTML(gu, dJ);
        } else {
            var gl = dp.ownerDocument.createRange(),
                lc = gu.indexOf("before") == 0,
                OU = gu.indexOf("Begin") != -1;
            if (lc == OU) {
                gl[lc ? "setStartBefore" : "setStartAfter"](dp);
                dp.parentNode.insertBefore(
                    gl.createContextualFragment(dJ), OU ? dp : dp.nextSibling);
            } else {
                var gj = dp[lc ? "lastChild" : "firstChild"];
                if (gj) {
                    gl[lc ? "setStartAfter" : "setStartBefore"](gj);
                    dp[lc ? "appendChild" : "insertBefore"](gl.createContextualFragment(dJ), gj);
                } else {
                    dp.innerHTML = dJ;
                }
            }
        }
        return true;
    } catch (aE) {
        return false;
    }
}
function setHTML(aNP, dJ) {
    var aMW = typeof aNP === "string" ? S(aNP) : aNP,
        aMX = aMW.cloneNode(false);
    aMX.innerHTML = dJ;
    aMW.parentNode.replaceChild(aMX, aMW);
    return aMX;
}
function isShow(wm, hB) {
    return (getStyle((typeof (wm) == "string" ? S(wm, hB) : wm), "display") || "none") != "none";
}
function show(wm, vd, hB) {
    var gj = (typeof (wm) == "string" ? S(wm, hB) : wm);
    if (gj) {
        gj.style.display = (vd ? "" : "none");
    } else if (!hB && typeof (wm) == "string") {

    }
    return gj;
}
var Show = show;
function toggle(wm, hB) {
    return show(wm, !isShow(wm, hB), hB);
}
function setClass(dp, ahG) {
    if (dp && typeof (ahG) != "undefined" && dp.className != ahG) {
        dp.className = ahG;
    }
    return dp;
}
function getStyle(dp, cdm) {
    var uH = dp && (dp.currentStyle ? dp.currentStyle : dp.ownerDocument.defaultView.getComputedStyle(dp, null));
    return uH && uH[cdm] || "";
}
function htmlDecode(cw) {
    return cw && cw.replace ? (cw.replace(/&nbsp;/gi, " ").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&amp;/gi, "&").replace(/&quot;/gi, "\"").replace(/&#39;/gi, "'")) : cw;
}
function htmlEncode(cw) {
    return cw && cw.replace ? (cw.replace(/&/g, "&amp;").replace(/\"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\'/g, "&#39;")) : cw;
}
function filteScript(cw, cNV) {
    return cw && cw.replace(/<script ?.*>(.*?)<\/script>/ig, "<script>$1\n</script>").replace(/<script ?.*>([\s\S]*?)<\/script>/ig, cNV || "");
}
function textToHtml(gc) {
    return ['<DIV>', gc.replace((gc.indexOf("<BR>") >= 0) ? /<BR>/ig : /\n/g, "</DIV><DIV>"), "</DIV>"].join("").replace(new RegExp("\x0D", "g"), "").replace(new RegExp("\x20", "g"), "&nbsp;").replace(new RegExp("(<DIV><\/DIV>)*$", "g"), "").replace(/<DIV><\/DIV>/g, "<DIV>&nbsp;</DIV>");
}
function textToHtmlForNoIE(gc) {
    return gc.replace(/\n/g, "<br>");
}
function htmlToText(gc) {
    return gc
        .replace(/\n/ig, "")
        .replace(/(<\/div>)|(<\/p>)|(<br\/?>)|(<\/li>)/ig, "\n");
}
function fixNonBreakSpace(cw) {
    return (cw || "").replace(/\xA0/ig, " ");
}
function pasteHTML(aFc, aBM, cTg, aB) {
    aB = aB || getMainWin();
    aFc = filteScript(aFc);
    var bJ = (typeof (aBM) == "string" ? S(aBM, aB) : aBM);
    if (!bJ || !aFc) {
        return false;
    }
    if (cTg) {
        bJ.innerHTML = aFc;
    } else {
        insertHTML(bJ, "afterBegin", aFc);
    }
    return true;
}
function T(jZ, qn) {
    return new T.yj(jZ, qn);
}
T.yj = function (jZ, qn, aC) {
    this.DK = jZ.join ? jZ.join("") : jZ.toString();
    this.xv = qn || "$";
    this.akc = aC == "exp" ? this.aki : this.aie;
};
T.yj.prototype = {
    toString: function () {
        return this.DK;
    },
    replace: function (jP, tp) {
        return this.akc(jP, tp);
    },
    aie: function (jP, akk) {
        var ad = this,
            tO = ad.xv,
            qo = ad.Pb,
            DA = ad.aiO,
            OD = !qo;

        if (OD) {

            qo = ad.Pb = ad.DK.split(ad.xv);
            DA = ad.aiO = ad.Pb.concat();
        }

        for (var i = 1, be = qo.length; i < be; i += 2) {
            DA[i] = ad.rK(OD ? (qo[i] = qo[i].split(".")) : qo[i], jP, akk, tO);
        }

        return DA.join("");
    },
    aki: function (jP, tp) {
        var ad = this,
            pz;

        if (!ad.Ox) {
            ad.afv();
        }

        if (tp) {
            var xm = ad.OT[tp];
            if (xm) {
                pz = typeof xm != "function" ? ad.OT[tp] = ad.Ow(xm) : xm;
            }
        } else {
            pz = ad.Ox;
        }

        try {
            return pz && pz(jP, ad.abh, ad.rK, ad.xv) || "";
        } catch (aE) {
            return aE.message;
        }
    },
    afv: function () {
        var ad = this,
            jU = 0,
            hU = [],
            DV = [],
            Df = [],
            ahq = ad.OT = [],
            tO = ad.xv,
            ng = new RegExp(["", "(.*?)", ""].join(regFilter(tO)), "g"),
            uu = "_afG('$1'.split('.'),_oD,_aoD,_aoR)",
            yh = ad.abh = ad.DK.split(["", "@", ""].join(tO)),
            eV;

        for (var i = 0, be = yh.length; i < be; i++) {
            eV = yh[i];

            if (i % 2 == 0) {
                hU.push("_oR.push(_aoT[", i, "].replace(_oD,_aoD));");
                yh[i] = T(eV, tO);
            } else if (eV == "else") {
                hU.push("}else{");
            } else if (eV == "endsec") {
                if (Df.length) {
                    var aQ = Df.pop();
                    ahq[aQ[0]] = hU.slice(aQ[1]);
                }
            } else if (eV == "endfor") {
                DV.length && hU.push("}_oD=_oS", DV.pop(), ";");
            } else if (eV == "endif") {
                hU.push("}");
            } else if (eV.indexOf("else if(") == 0) {
                hU.push("}", eV.replace(ng, uu), "{");
            } else if (eV.indexOf("if(") == 0) {
                hU.push(eV.replace(ng, uu), "{");
            } else if (eV.indexOf("for(") == 0) {
                DV.push(++jU);
                hU.push("var _sI", jU, ",_oD", jU, ",_oS", jU, "=_oD;", eV.replace(ng, ["_sI", jU, " in (_oD", jU, "=", uu, ")"].join("")), "{", "_oD=_oD", jU, "[_sI", jU, "];", "if(!_oD){continue;}", "_oD._parent_=_oS", jU, ";", "_oD._idx_=_sI", jU, ";");
            } else if (eV.indexOf("sec ") == 0) {
                Df.push([eV.split(" ").pop(), hU.length]);
            } else if (eV.indexOf("eval ") == 0) {
                hU.push("_oR.push(", eV.substr(5).replace(ng, uu), ");");
            }
        }

        ad.Ox = ad.Ow(hU);

        return hU;
    },
    Ow: function (akN) {
        try {
            return eval(['([function(_aoD,_aoT,_afG,_aoR){var _oR=[],_oD=_aoD;', akN.join(""), 'return _oR.join("");}])'].join(""))[0];
        } catch (fj) {
            return function () {
                return "compile err!"
            };
        }
    },
    rK: function (Dw, jP, ajV, adA) {
        var be = Dw.length,
            dA, iP;
        if (be > 1) {
            try {
                iP = jP;
                for (var i = 0; i < be; i++) {
                    dA = Dw[i];
                    if (dA == "_root_") {
                        iP = ajV;
                    } else {
                        iP = iP[dA];
                    }
                }
            } catch (aE) {
                iP = "";
            }
        } else {
            iP = {
                "_var_": adA,
                "_this_": jP
            }[dA = Dw[0]] || jP[dA];
        }

        return iP;
    }
};
var addEvent = (function () {

    function zx(sg, aC, avL, EU) {
        if (sg && avL) {
            if (sg.addEventListener) {
                sg[EU ? "removeEventListener" : "addEventListener"](
                    aC, avL, false);
            } else if (sg.attachEvent) {
                sg[EU ? "detachEvent" : "attachEvent"]("on" + aC, avL);
            } else {
                sg["on" + aC] = EU ? null : avL;
            }
        }

        return sg;
    }

    return function (sg, aC, bOv, EU) {
        if (sg && (sg.join || sg[bpO])) {
            E(sg, function (ar) {
                zx(ar, aC, bOv, EU);
            });
        } else {
            zx(sg, aC, bOv, EU);
        }

        return sg;
    };
})();
function addEvents(sg, wG, EU) {
    E(wG, function (zY, aC) {
        addEvent(sg, aC, zY, EU);
    });
    return sg;
}
function removeEvent(sg, aC, avL) {
    return addEvent(sg, aC, avL, true);
}
function removeEvents(sg, wG) {
    return addEvents(sg, wG, true);
}
function preventDefault(ag) {
    if (ag) {
        if (ag.preventDefault) {
            ag.preventDefault();
        } else {
            ag.returnValue = false;
        }
    }
    return ag;
}
function stopPropagation(ag) {
    if (ag) {
        if (ag.stopPropagation) {
            ag.stopPropagation();
        } else {
            ag.cancelBubble = true;
        }
    }
    return ag;
}
function getEventTarget(ag) {
    return ag && (ag.srcElement || ag.target);
}
function fireMouseEvent(dp, bsx) {
    if (dp) {
        if (dp.dispatchEvent) {
            var bu = dp.ownerDocument,
                aR = bu.defaultView,
                cp = bu.createEvent("MouseEvents");
            cp.initMouseEvent(bsx, true, true, aR, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
            dp.dispatchEvent(cp);
        } else {

            if (dp.tagName == "INPUT" && dp.getAttribute("type") == "submit" && bsx == "click") {
                dp.click();
            } else {
                dp.fireEvent("on" + bsx);
            }
        }
    }
    return dp;
}
function QMAjax(aD, sP, Dy, iA) {
    var ad = this,
        aj = getTop(),
        oE = iA,
        eC;

    function coG() {
        ad.onComplete(oE);
    }

    function bLB(eg) {
        ad.onError(oE, eg);
    }

    function bSt(caO) {
        if (!eC) {
            eC = setTimeout( function () {
                ad.abort();
            }, caO);
        }
    }

    function ali(eg) {
        if (eC) {
            clearTimeout(eC);
            eC = null;
            if (eg != "ok") {
                bLB(eg);
            }
            return true;
        }
        return false;
    }

    this.method = sP || "POST";
    this.url = aD;
    this.async = true;
    this.content = "";
    this.timeout = Dy;

    this.onComplete = function () {
    };
    this.onError = function () {
    };
    if (!oE) {
        try {
            oE = new XMLHttpRequest;
        } catch (aE) {
            try {
                oE = new ActiveXObject("MSXML2.XMLHTTP");
            } catch (aE) {
                try {
                    oE = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (aE) {
                }
            }
        }
    }

    if (!oE) {
        return false;
    }

    this.abort = function () {
        ali("abort");
        oE.abort();
    };
    this.send = function (cfl) {
        if (!this.method || !this.url || !this.async) {
            return false;
        }

        typeof this.url == "object" && (this.url = this.url.replace({}));

        var gE = this.method.toUpperCase(),
            fy = "";
        this.abort();

        oE.open(gE, this.url + (fy && gE == "POST" ) , this.async);

        if (gE == "POST") {
            oE.setRequestHeader("Content-Type", document.charset);
            oE.setRequestHeader("Content-length", this.content.length);
            oE.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        }

        aj.E(this.headers, function (aK, cr) {
            oE.setRequestHeader(cr, aK);
        });
        oE.onreadystatechange = function () {
            try {
                if (oE.readyState == 4) {
                    if (oE.status == 200) {
                        if (ali("ok")) {
                            coG();
                        }
                    } else {
                        ali(oE.status);
                    }
                }
            } catch (cs) {
                ali(cs.message);
            }
        }
        bSt(this.timeout || 15000);

        try {
            if (gE == "POST") {
                oE.send(cfl || this.content);
            } else {

                oE.send(null);
            }
        } catch (aE) {
            ali(aE.message);
        }

        return true;
    }
};

QMAjax.send = function (aD, an, bRS) {
    var aj = getTop(),
        eG = bRS || new QMAjax,
        bw = an || {};
    eG.url = aD;

    aj.E("method,timeout,content,headers".split(","), function (cr) {
        if (bw[cr]) {
            eG[cr] = bw[cr];
        }
    });
    eG.onComplete = function (iA) {
        aj.callBack.call(iA, an.onload, [true, aj.trim2(iA.responseText || ""), iA]);

    };
    eG.onError = function (iA, eg) {
        aj.callBack.call(iA, an.onload, [false, eg, iA]);
    };
    eG.send();
}
function includeAjax(aB) {

    var jH = [];
    jH.push(QMAjax.toString());
    jH.push(["var QMAjaxSend =", QMAjax.send.toString()].join(""));
    globalEval(jH.join(""), aB);

}
var QMAjaxRequest = QMAjax;
function getErrMsg(iA, cmo) {
    var aro = "_AjaxErrorHTML_";
    var EB = S(aro);
    if (!EB) {
        EB = document.createElement("div");
        EB.id = aro;
        EB.style.display = "none";
        document.body.appendChild(EB);
    }
    EB.innerHTML = filteScript(iA.status == 200 ? iA.responseText : "");
    var VU = S(cmo);
    return VU && (VU.innerText || VU.textContent) || "";
}
function getHttpProcesser() {
    var aj = getTop(),
        aVn = aj.gCurHttpProcesserId || 0;

    aj.gCurHttpProcesserId = (aVn + 1) % 30;

    try {
        if (aj.gHttpProcesserContainer[aVn] != null) {
            delete aj.gHttpProcesserContainer[aVn];
        }
    } catch (aE) {
        aj.gHttpProcesserContainer = {};
    }

    var bJS = aj.gHttpProcesserContainer[aVn] = new aj.Image;
    bJS.onload = function () {
        return false;
    };
    return bJS;
}
function getTopWin() {
    return getTop();
}
function getMainWin() {
    return F("mainFrame", getTop()) || getTop();
}
function getActionWin() {
    return F("actionFrame", getTopWin());
}
function getLeftWin() {
    return getTop();
}
var GetLeftWin = getLeftWin;
function msgBox(aJ, auq, aTx, VL, cdE, aB) {
    if (window != getTop()) {
        return getTop().msgBox(aJ, auq, aTx, VL, cdE, aB);
    }

    var aF = aJ;

    if (!aF) {
        var awC = S("msg_txt", aB || window) || S("msg_txt", getActionWin());

        if (awC && (awC.innerText || awC.textContent) && awC.getAttribute("ok") != "true") {
            aF = filteScript(awC.innerHTML);
            awC.setAttribute("ok", "true");
        }
    }

    if (!aF || !(aF = trim(aF.replace(/[\r\n]/ig, "")))) {
        return;
    }

    hiddenMsg();

    if (auq == "dialog") {
        alertBox({
            msg: aF,
            title: cdE || "确认"
        });
    } else {
        setClass(arguments.callee.createMessageBox().firstChild, auq == "success" ? "msg" : "errmsg").innerHTML = aF;

        showMsg();
        if (aTx) {
            getTop().gMsgBoxTimer = getTop().setInterval(getTop().hiddenMsg, VL || 5000);
        }

        getTop().gMsgDispTime = now();
    }
};
msgBox.createMessageBox = function (Vy) {
    var aIC = S("msgBoxDIV", getTop());
    if (!aIC) {

        var dj = typeof Vy == "undefined" ? (getTop().bnewwin ? 0 : 43) : Vy;

        var doc = document;
        doc = (doc.compatMode != "CSS1Compat") ? doc.body : doc.documentElement;
        var el = doc;
        var x, y;
        if (gbIsOpera || gbIsIE) {
            x = el.scrollLeft;
            y = el.scrollTop;
        } else {
            x = window.scrollX;
            y = window.scrollY;
        }
        var scrollPos =  {x : x, y : y};
        x = Math.round(scrollPos.x + (el.clientWidth ) / 2);
        y = Math.round(scrollPos.y + (el.clientHeight ) / 2);
        insertHTML(
            getTop().document.body, "afterBegin", T(['<div id="msgBoxDIV" style="position:absolute;width:100%;display:none;', 'padding-top:2px;height:24px;*height:24px;_height:20px;top:$top$px;text-align:center;">', '<span></span>', '</div>']).replace({
                top: y
            }));
        aIC = S("msgBoxDIV", getTop());
    }
    return aIC;
};
function isshowMsg() {
    return getTop().isShow("msgBoxDIV");
}
function hiddenMsg() {
    if (getTop().gMsgBoxTimer) {
        getTop().clearInterval(getTop().gMsgBoxTimer);
        getTop().gMsgBoxTimer = null;
    }
    getTop().show("msgBoxDIV", false);
}
function showMsg() {
    getTop().show("msgBoxDIV", true);
}
function showError(kk, VL) {
    msgBox(kk, "", VL != -1, VL || 5000);
}
function showInfo(dbM, VL) {
    msgBox(dbM, "success", VL != -1, VL || 5000);
}
function runUrlWithSid(url) {

    try {
        getTop().getHttpProcesser().src = T('$url$&r=$rand$').replace({
            url: url,
            rand: Math.random()
        });
    } catch (aE) {
    }
}

// 实用工具类
var IWB_UTIL = {
    timedesc: function (nowtime,timestamp) {
        var diff = nowtime - timestamp;
        var nowtimeDate = new Date(nowtime*1000);
        var previousDayDate = new Date( (nowtime - 24 * 3600) * 1000 );
        var timestampDate = new Date(timestamp*1000);
        var timestampYear = timestampDate.getFullYear();
        var timestampMonth = timestampDate.getMonth();
        var timestampDay = timestampDate.getDate();
        var timestampHours = timestampDate.getHours()<10?"0"+timestampDate.getHours():timestampDate.getHours();
        var timestampMinutes = timestampDate.getMinutes()<10?"0"+timestampDate.getMinutes():timestampDate.getMinutes();

        if(diff < 60){
            return "刚刚";
        }else if(diff < 3600){
            return Math.floor(diff/60)+"分钟前";
        }

        if(nowtimeDate.getFullYear() == timestampYear){
            if(nowtimeDate.getMonth() == timestampMonth){
                if(nowtimeDate.getDate() == timestampDay){
                    return "今天"+timestampHours+":"+timestampMinutes;
                }else if( previousDayDate.getDate() == timestampDay ){
                    return "昨天"+timestampHours+":"+timestampMinutes;
                }else{
                    return [timestampMonth+1,"月",timestampDay,"日"," ",timestampHours,":",timestampMinutes].join("");
                }
            }else{
                return [timestampMonth+1,"月",timestampDay,"日"," ",timestampHours,":",timestampMinutes].join("");
            }
        }else{
            return [timestampYear,"年",timestampMonth+1,"月",timestampDay,"日"," ",timestampHours,":",timestampMinutes].join("");
        }
    }
};
/////////////////
(function(_aoWin)
{
	var _oTop = getTop(),
		_oAni = _oTop.qmAnimation,
		_style = function(_aoDom, _asAttr, _anValue)
		{
			if (typeof _anValue == "undefined")
			{
				return parseInt( _aoDom.style[_asAttr] );
			}
			else
			{
				_aoDom.style[_asAttr] = _anValue + "px";
			}
		},
		_S = function(_asId)
		{
			return _oTop.S(_asId, _aoWin);
		};

	_aoWin.pageReady = function()
	{
		
		var _oFx = _S("fx"),
			_oFrameBox = _S("frameBox"),
			_oQQml = _S("qqml"),
			_oFrameCon = _S("frameCon"),
			_oMaskObj = _S("mask_obj"),
			_oLoadMoreComment = _S("commentMore"),
			_nFoldHeight,
			_nExpandHeight;
		floadComments(_oTop.attr(_oLoadMoreComment,"colid"));	
		loadScores();
		var _fx = function()
		{
			var _sState = _oTop.attr(_oFx, "state");
			if (!_nFoldHeight || !_nExpandHeight)
			{
				_nFoldHeight = _oFrameBox.offsetHeight;
				_nExpandHeight = _oQQml.offsetHeight + 110;
			}
			if (_sState == "expand")
			{
				//fold it
				_oAni.play(_oFrameBox,
				{
					win : _aoWin,
					speed : 600,
					from : _nExpandHeight, 
					to : _nFoldHeight,
					onready : function()
					{
						_oFrameCon.style.zoom = 0.9; 
						_oMaskObj.style.cursor = 'pointer';	
						_oMaskObj.style.height = 400 +'px';
					},
					onaction : function(_anValue, _anProcess)
					{
						//_oFrameCon.style.zoom = 1 - 0.1*_anProcess;
						_style(_oFrameBox, "height", _anValue);
					},
					oncomplete : function(_anValue, _anProcess)
					{
						_style(_oFrameBox, "height", _anValue);
						_oTop.attr(_oFx, "state", "fold");
						_oTop.setClass(_oFx, "btn_unfold");
					}
				});
			}
			else
			{
				//expand it
				_oAni.play(_oFrameBox,
				{
					win : _aoWin,
					speed : 600,
					from : _nFoldHeight, 
					to : _nExpandHeight,
					onready : function()
					{
						_oFrameCon.style.zoom = 1; 
						_oMaskObj.style.cursor = 'default';
						_oMaskObj.style.height = _nExpandHeight+'px';
						
					},
					onaction : function(_anValue, _anProcess)
					{
						//_oFrameCon.style.zoom = 0.9 + 0.1*_anProcess;
						_style(_oFrameBox, "height", _anValue);
					},
					oncomplete : function(_anValue, _anProcess)
					{
						_style(_oFrameBox, "height", _anValue);
						_oTop.attr(_oFx, "state", "expand");
						_oTop.setClass(_oFx, "btn_fold");
					}
				});
			}
		}
		_oTop.addEvent(_oFx, "click", _fx); 
		_oTop.addEvent(_oMaskObj, "click", _fx); 
		
		var _oPoint = SN("starPoint"),
			_oTxtDom = _S("pointTxt"),
			_nStar = 0,
			_oTxt = ["","非常差，内容质量十分低劣。","比较差，达不到我的预期。","还行，无聊的时候可以看看。","推荐，值得一看。","强烈推荐，精彩内容不容错过！"];
		function _changeStar(_aoStarDom,_anPoint)
		{
			var _bStarSeted = false;
			_oTop.E(_oPoint,function(_aoDom)
			{
				_bStarSeted || _oTop.setClass(_aoDom,"star");
				_anPoint && _bStarSeted && _oTop.setClass(_aoDom,"s_1");
				if (_aoDom == _aoStarDom)
				{
					_bStarSeted = true;
				}
			});
		}
		function _overStar( _aoStarDom)
		{
			_oTxtDom.innerHTML = _oTxt[ _oTop.attr(_aoStarDom,"point")];
			_changeStar(_aoStarDom);
		}
		function _clearStar()
		{
			_oTop.E(_oPoint,function(_aoDom)
			{
				if (!_nStar)
				{
					_oTop.setClass(_aoDom,"s_1");
					_oTxtDom.innerHTML = _oTxt[0];
				}
				else
				{
					if (_oTop.attr(_aoDom,"point") <= _nStar)
					{
						_oTop.setClass(_aoDom,"star");
					}
					else
					{
						_oTop.setClass(_aoDom,"s_1");
					}
					_oTxtDom.innerHTML = _oTxt[_nStar];
				}
			});
		}
		function _setStar(_aoSelectDom)
		{
            //&__mailid__
			var _oInversgationUrl = _oTop.T( "/dy/ctm?1=__ctmvalue__&2=__colid__&3=__title__", "__" ),
				_sColid = _oTop.attr(_aoSelectDom.parentNode,"colid"),_nPoint = _oTop.attr(_aoSelectDom,"point"),_sTitle = _oTop.attr(_aoSelectDom.parentNode,"stitle"),
				_sUrl = _oInversgationUrl.replace(
				{
					ctmvalue : _nPoint,
					colid : _sColid, 
					title : _sTitle,
					mailid : "" 
				});
			_changeStar(_aoSelectDom,_nPoint);
			_nStar = _nPoint;
			_oTop.S("pointTxt",window).innerHTML = "评价成功！";
			jQuery.ajax({
		         type:"GET",url:_sUrl,data:"",dataType:"html",
		         success:function(_asParam)
		 		{
		 			 
		 		}
		     });
			
			
		}
		function _getLastId(){
			var _nLastId = document.getElementById("commentContainer");
			if(_nLastId.hasChildNodes()){
				var x=_nLastId.lastChild;
				if(x.nodeType!=1)x=x.previousSibling;
				_nLastId = x==null ? null :x.getAttribute("lastrowid");
			}else{
				_nLastId=null;
			}
			if(_nLastId==null||_nLastId==undefined||_nLastId==""||_nLastId=="undefined"){
				_nLastId = _oTop.S("commentMore",window).getAttribute("lastrowid");
			}
			return _nLastId;
		}
		function loadScores(){
			//&__mailid__
			var _oInversgationUrl = _oTop.T( "/dy/s?1=__colid__", "__" ),
			_oHot = _oTop.S("s_star",window),
			_sColid = _oTop.attr(_oHot,"colid"),
			_sUrl = _oInversgationUrl.replace(
			{
				colid : _sColid, 
				mailid : "" 
			});
            jQuery.ajax({
		         type:"GET",url:_sUrl,data:"",dataType:"html",
		         success:function(_asParam)
		 		{
		        	var _oHot = _oTop.S("g_score",window);
		        	_oTop.setHTML(_oHot, _asParam);
		 		}
		     });
		}
		function floadComments( _asColid )
		{
			var _sUrl = "/comment/ct?" ,
				_oHot = _oTop.S("commentContainer",window),
				_nLastId = '2147483647',
				_sContent = "1=" + _asColid + "&2=" + _nLastId,
				_oLoading =_oTop.S("loadingmore",window),
				_oComment = _oTop.S("commentMore",window);			
			
			_oTop.show(_oLoading,true);
			_oTop.show(_oComment,false);
            jQuery.ajax({
		         type:"GET",url:_sUrl+_sContent,data:"",dataType:"json",
		         success:function(_asParam){
				 	var html='';
 					for(obj in _asParam.ret){
						html+=
						 '<li lastrowid="' + _asParam.ret[obj].comment_id + '"> <h3 class="user_name">' + _asParam.ret[obj].username +
						 '</h3> <span class="time">' + IWB_UTIL.timedesc ( _asParam.timestamp,  _asParam.ret[obj].dateline ) + 
						 '</span> <p class="c_detail">' + _asParam.ret[obj].content + '</p> </li>';
					}
		 			var 
		 			_oHot = _oTop.S("commentContainer",window),
		 			_oLoading =_oTop.S("loadingmore",window),
		 			_oComment = _oTop.S("commentMore",window);
		 			_oTop.show(_oLoading,false);
		 			
		 			_oTop.setHTML(_oHot, html);
		 			_asParam != "" && _oTop.show(_oComment,true);
		 		}
		     });
		}
		function loadComments( _asColid )
		{
			var _sUrl = "/comment/ct?" ,
				_oHot = _oTop.S("commentContainer",window),
				_nLastId = _getLastId();
				_sContent = "1=" + _asColid + "&2=" + _nLastId,
				_oLoading =_oTop.S("loadingmore",window),
				_oComment = _oTop.S("commentMore",window);			
			
			_oTop.show(_oLoading,true);
			_oTop.show(_oComment,false);
            jQuery.ajax({
		         type:"GET",url:_sUrl+_sContent,data:"",dataType:"json",
		         success:function(_asParam){
				 	var html='';
 					for(obj in _asParam.ret){
                        alert(_asParam.ret[obj].comment_id);
						html+=
						 '<li lastrowid="' + _asParam.ret[obj].comment_id + '"> <h3 class="user_name">' + _asParam.ret[obj].username +
						 '</h3> <span class="time">' + IWB_UTIL.timedesc ( _asParam.timestamp,  _asParam.ret[obj].dateline ) + 
						 '</span> <p class="c_detail">' + _asParam.ret[obj].content + '</p> </li>';
					}
		 			var  
		 			_oHot = _oTop.S("commentContainer",window),
		 			_oLoading =_oTop.S("loadingmore",window),
		 			_oComment = _oTop.S("commentMore",window);
		 			_oTop.show(_oLoading,false);
		 			_oTop.insertHTML(_oHot,"beforeEnd",html);
		 			_asParam != "" && _oTop.show(_oComment,true);
		 		}
		     });
		}
		_oLoadMoreComment && (_oTop.addEvent(_oLoadMoreComment,"click",function()
		{
			loadComments(_oTop.attr(_oLoadMoreComment,"colid"));
		}));
		_oTop.E(_oPoint,function(_aoDom)
		{
			_oTop.addEvent(_aoDom,"mouseover",function()
			{
				_overStar(_aoDom);
			});
			_oTop.addEvent(_aoDom,"mouseout",_clearStar);
			_oTop.addEvent(_aoDom,"click",function()
			{
				_setStar(_aoDom);
			}
			);
		});

	}
})(window);